<?php
/**
 * @since v1.0
 * @modify 2015.6.21
 * @copyright 深圳亿游
 */
require_once(LIB_PATH.'controller/root.con.php');

class reportCon extends rootCon
{
    public function infoAction() {
        $uid = mylogin::getUid(true);
        $obj = new Report();
        $objId = r_int($obj->key());
        if($objId){
            $find = $obj->find([[$obj->key(),$objId],['uid',$uid]]);
            if(!$find){
                $this->j(-1,'没有找到对应的信息',[$obj->key()=>$objId]);
            }else{
                $obj->hide();
                $this->j(0,'详情',$obj->arr);
            }
        }

        $this->j(-2,'系统居然出错了',[$obj->key()=>$objId]);
    }

    public function saveAction() {
        $uid = mylogin::getUid(true);
        $obj = new Report();
        $objId = r_int($obj->key());
        if($objId){
            $find = $obj->find([['invoiceId',$objId],['uid',$uid]]);
            if(!$find){
                $this->j(-1,'没有找到对应的发票信息',['invoiceId'=>$objId]);
            }
        }
        $obj->load();
        $obj->uid = $uid;
        $obj->ip  = myrequest::getIP();
        $obj->created = date('Y-m-d H:i:s');
        $obj->save();
        $obj->hide();
        $this->j(0,'保存成功',$obj->arr);
    }

    public function listAction() {
        $uid = mylogin::getUid(true);
        $obj = new Report();
        $result = $obj->getArrayResult(['uid'=>$uid]);

        $this->j(0, "发票信息列表",$result);
    }
}



